package cn.iocoder.an.module.business.controller.admin.repairrequest.vo;

import cn.iocoder.an.module.business.controller.admin.repairtask.vo.RepairTaskRespVO;
import cn.iocoder.an.module.business.dal.dataobject.equipmentmanage.EquipmentManageDO;
import cn.iocoder.an.module.business.dal.dataobject.faultclassification.FaultClassificationDO;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fhs.core.trans.anno.Trans;
import com.fhs.core.trans.constant.TransType;
import com.fhs.core.trans.vo.VO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.math.BigDecimal;
import java.util.*;

import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

import cn.idev.excel.annotation.*;
import cn.iocoder.an.framework.excel.core.annotations.DictFormat;
import cn.iocoder.an.framework.excel.core.convert.DictConvert;

@Schema(description = "管理后台 - 维修申请 Response VO")
@Data
@ExcelIgnoreUnannotated
public class RepairRequestRespVO implements VO {

    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31397")
    @ExcelProperty("id")
    private Long id;

    @Schema(description = "申请单号", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("申请单号")
    private String repairNo;


    //提交人
    //跨模块翻译 添加targetClassName
    @Trans(type = TransType.SIMPLE, targetClassName = "cn.iocoder.an.module.system.dal.dataobject.user.AdminUserDO", fields = "nickname", ref = "creatorUserName")
    private String creator;

    @ExcelProperty("提交人")
    private String creatorUserName;

    //数据翻译记得在类上实现VO接口 还要在controller接口上添加 @TransMethodResult注解
    @Trans(type = TransType.SIMPLE, target = FaultClassificationDO.class, fields = "name", ref = "faultName")
    private Long faultId;

    @Schema(description = "故障名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "13506")
    private String faultName;

    @Schema(description = "设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16075")
    @Trans(type = TransType.SIMPLE, target = EquipmentManageDO.class,   fields = {"equipmentModel", "deptName","code"},refs = {"equipmentModel", "deptName","code"})
    private Long equipmentId;

    @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
    @ExcelProperty("设备名称")
    private String equipmentName;

    @Schema(description = "设备型号", requiredMode = Schema.RequiredMode.REQUIRED, example = "xxx-5")
    private String equipmentModel;

    @Schema(description = "所属部门", requiredMode = Schema.RequiredMode.REQUIRED, example = "信息部")
    private String deptName;

    @Schema(description = "设备编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "0014")
    @ExcelProperty("设备编码")
    private String code;

    @Schema(description = "故障发生时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("故障发生时间")
    private LocalDateTime faultTime;

    @Schema(description = "申请人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3650")
    private Long requestUserId;

    @Schema(description = "申请人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
    @ExcelProperty("申请人")
    private String requestUserName;

    @Schema(description = "紧急程度", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "紧急程度", converter = DictConvert.class)
    @DictFormat("urgency") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private Integer urgency;

    @Schema(description = "故障描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
    @ExcelProperty("故障描述")
    private String description;

    @Schema(description = "维修方式", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty(value = "维修方式", converter = DictConvert.class)
    @DictFormat("repair_type") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private Integer repairWay;

    @Schema(description = "维修人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "661")
    private List<Long> dutyUserId;

    @Schema(description = "维修人名称", example = "李四")
    @ExcelProperty("维修人名称")
    private String dutyUserName;

    @Schema(description = "状态", example = "1")
    @ExcelProperty(value = "状态", converter = DictConvert.class)
    @DictFormat("repair_status") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private Integer status;

    @Schema(description = "是否解决")
    @ExcelProperty("是否解决")
    private Integer resolved;

    @Schema(description = "期望解决日期")
    @ExcelProperty("期望解决日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date expectedResolveTime;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("创建时间")
    private LocalDateTime createTime;

    @ExcelIgnore
    private RepairTaskRespVO taskRespVO;

    @ExcelIgnore
    private List<RepairTaskRespVO> taskRespVOList;

    @Schema(description = "维修次数", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer repairCount;

    @Schema(description = "维修总时长(小时)", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "#.##", locale = "en-US")
    private Double repairHours;

    @Schema(description = "维修成本", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "#0.00")
    private BigDecimal totalCost;



}